package ed.hbut.supermarket1.service.impl;

import ed.hbut.supermarket1.entity.Category;
import ed.hbut.supermarket1.mapper.CategoryMapper;
import ed.hbut.supermarket1.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    CategoryMapper categoryMapper;

    @Override
    public List<Category> getAllCategory() {

        return categoryMapper.getAllCategory();
    }

    @Override
    public void addCategory(Category category) {
        System.out.println(category);
         Integer quantity= categoryMapper.setCategoryQuantities(category.getCategoryId());
        category.setCategoryQuantity(quantity);
        categoryMapper.add(category);
    }

    @Override
    public void updateCategory(Category category) {
        categoryMapper.updateCategory(category);

    }

    @Override
    public void delete(Integer id) {
         categoryMapper.delete(id);
    }
}
